﻿#include "systemsetting.h"
#include "ui_systemsetting.h"
#include <QDir>
#include <QSettings>
#include <QMessageBox>
#include "laguagecontroller.h"
SystemSetting::SystemSetting(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SystemSetting)
{
    ui->setupUi(this);
    ui->chinese_Rbtn->setChecked(true);
    sender = new QUdpSocket(this);
}

SystemSetting::~SystemSetting()
{
    delete ui;
}

//切换成中文
void SystemSetting::on_chinese_Rbtn_clicked()
{
    LaguageController::getInstance()->setCurrentLanguage(Chinese_E);
}

//切换成英文
void SystemSetting::on_english_Rbtn_clicked()
{
    LaguageController::getInstance()->setCurrentLanguage(English_E);
}

void SystemSetting::on_reset_pushButton_clicked()
{
    QString dirPath = "./DependFile/conf/";
    QDir confdir(dirPath);
    if(!confdir.exists())
        confdir.mkdir(dirPath);
    QString confFile(dirPath + "IDconf.ini");
    QSettings iniSetting(confFile, QSettings::IniFormat);
    QString password("111111");
    iniSetting.setValue("password",password);
    iniSetting.setValue("user","xyyl");
    QMessageBox::warning(NULL,tr("提示"),tr("密码重置成功"));
}

//传感器校准
void SystemSetting::on_calibration_pushButton_clicked()
{


}

void SystemSetting::changeEvent(QEvent* event)
{
    switch (event->type())
    {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        QWidget::changeEvent(event);
        break;
    }
}
